home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / mflms101.arc / TEKNOTES.DOC < prev    next >
Text File  |  1989-11-25  |  10KB  |  397 lines

  1. TITLE_PG.TN - Thu 23 Nov 89 00:20 - Page 1:  
  2.  
  3.     
  4.     
  5.     
  6.     
  7.     
  8.     
  9.     
  10.     
  11.     
  12.     
  13.     
  14.     
  15.                           The MicroFirm Function Library
  16.                              for Microsoft C & Quick C
  17.                                       ver 1.01
  18.     
  19.                  Copyright 1988-89 by Robert B. Stout dba MicroFirm
  20.                   portions Copyright 1986-87 by Stephen E. Margison
  21.                                 All rights reserved
  22.     
  23.     
  24.     
  25.     
  26.     
  27.                           -------------------------------
  28.                           TECHNICAL NOTES ON RELEASE 1.01
  29.                           -------------------------------
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. TOC.TN - Thu 23 Nov 89 00:20 - Page 2:  
  68.  
  69.     
  70.     
  71.     
  72.     
  73.     
  74.     
  75.     
  76.     
  77.     
  78.     
  79.     
  80.     
  81.     
  82.     
  83.     
  84.     The MicroFirm Funtion Library - Technical notes on release 1.01
  85.     
  86.     
  87.     Page    Topic
  88.     
  89.       3     Object-oriented features of ver 1.01 - future C++ directions
  90.       4     High-level stream I/O
  91.       5     BASIC-like string functions
  92.       6     Julian (scalar) date functions
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. OOPS.TXT - Thu 23 Nov 89 00:20 - Page 3:  
  134.  
  135.     The MicroFirm Function Library includes several groups of functions
  136.     which, not accidentally, lend themselves to an object-oriented view of
  137.     programming. Future versions of The MicroFirm Function Library will, in
  138.     fact, include C++ class implementations of some of these:
  139.     
  140.     
  141.     Stream I/O
  142.     ----------
  143.     
  144.     The high-level stream I/O functions and their associated installable
  145.     stream filter functions are the most obvious candidates for conversion
  146.     to classes. These are already written to hide the functional code and
  147.     data structures as much as possible from the implementation.
  148.     
  149.     
  150.     BASIC-like string handling
  151.     --------------------------
  152.     
  153.     It seems everyone who does C++ classes includes a string class, so why
  154.     should I be different? As such classes go, the functions in The
  155.     MicroFirm Function Library are quite conservative, yet addresss the
  156.     requirements of most programmers who are simply looking for the ease of
  157.     BASIC-like string processing in C.
  158.     
  159.     
  160.     Math
  161.     ----
  162.     
  163.     The specialized math routines for performing CRC calculations, integer
  164.     square roots, and simultaneous divide and modulus can all be coded in
  165.     C++ so that separate versions need not be called for different data
  166.     types as is the case with the C versions.
  167.     
  168.     
  169.     Directory operations
  170.     --------------------
  171.     
  172.     Although written for compatibility with BSD 4.3 the opendir(), readdir()
  173.     and closedir() functions could well be treated as a C++ class.
  174.     
  175.     
  176.     Filename processing
  177.     -------------------
  178.     
  179.     The MicroFirm Function Library's extensive facilities for normalizing
  180.     filenames, explicit smart wildcard matching, etc. could be enhanced by
  181.     the implementation of a DOS filename class.
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. STREAMIO.TXT - Thu 23 Nov 89 00:20 - Page 4:  
  200.  
  201.     The MicroFirm Function Library's stream I/O is a unique (for now)
  202.     approach to high-level file I/O. Analogous to a shell's (e.g. DOS's
  203.     COMMAND.COM) ability  to pipe and/or redirect file I/O, the stream I/O
  204.     functions provide the ability to install filters in the stream. Examples
  205.     included in the release of The MicroFirm Function Library include
  206.     filters to force streams to either upper or lower case, to encrypt or
  207.     decrypt streams, and to perform simple run-length encoding. Note that
  208.     the use of these filters is totally transparent to the application.
  209.     
  210.     Another unique feature of The MicroFirm Function Library's stream I/O is
  211.     the ability to treat external data channels (e.g. interrupt-driven
  212.     serial I/O functions) as if they are simply another stream device like a
  213.     disk file. In order for this to work, the minimum requirement is for
  214.     appropriate functions to exist which function analogously to the normal
  215.     fgetc() and fputc() functions. A function to unget a character may also
  216.     be required (see below).
  217.     
  218.     Filters installed in streams are installed as if on a stack and invoked
  219.     in a last installed, first called fashion. Only one filter may be
  220.     installed which alters the number of characters transmitted to or from a
  221.     stream. An example of such filters are the run-length encoding filters
  222.     included in this library. These are not particularly useful as written
  223.     (sorry - ran out of time to do LZHuff or arithmetic coding filters), but
  224.     demonstrate how to write such filters. Since such filters must have the
  225.     ability to gobble or source characters not in the original stream, they
  226.     must be stacked immediately before or after the stream destination or
  227.     source, respectively. This means such filters acting on a stream opened
  228.     for writing must be installed first in the chain (last called). Such
  229.     filters installed in a stream opened for reading must be installed last
  230.     (first called). Note that, since character sinking or sourcing is done
  231.     within such a filter, the character count reported by the sfread() and
  232.     sfwrite() functions is the number of characters without such processing.
  233.     For example, if I read in 1024 characters from a file then pass them
  234.     through a compression filter to another file, sfwrite() will return 1024
  235.     as the number of characters written even though the number of characters
  236.     physically written was smaller due to the action of the compression
  237.     filter. Similarly, if I read the compressed file back through an
  238.     expansion filter, sfread() will report that I read 1024 character from a
  239.     file which may have been physically smaller since it was compressed.
  240.     
  241.     There are two other requirements of filters which must have the ability
  242.     alter the stream's character count. If such a stream is opened for
  243.     reading, it must provide an unget-equivalent function to allow it to
  244.     replace unused characters in the stream. If a stream is opened for
  245.     writing, it must provide a flush function to force unprocessed output to
  246.     the stream when the stream is closed.
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265. BASTRNGS.TXT - Thu 23 Nov 89 00:20 - Page 5:  
  266.  
  267.     The MicroFirm Function Library provides the unique ability for C
  268.     programmers to process character arrays (strings) as simply as most
  269.     BASIC programmers (or C++ programmers!) It does this by maintaining and
  270.     reusing a pool of string space. Note that since these strings are
  271.     reused, to retain permanent copies requires the use of strcpy() or
  272.     strdup(). This is an inconvenience at times but avoids the overhead
  273.     inherent in "garbage collection" algorithms such as used by BASIC. Most
  274.     times, the strings will be used before their string space is reused.
  275.     
  276.     The primary function of this package is stralloc() which returns a
  277.     string buffer from the pool which is guaranteed to be large enough to
  278.     hold a string of the requested size. The stralloc() function is called
  279.     internally by several of the other functions and is available for use by
  280.     applications needing a temporary string storage buffer.
  281.     
  282.     The string pool defaults to 16 strings in small and compact models and
  283.     64 strings in large and medium models, with all strings dynamically
  284.     resized as required. Where these are too few, the str_init() function
  285.     allows up to 128 strings in small and compact model or up to 512 strings
  286.     in large and medium model. To avoid possible problems when used by
  287.     recursive functions or functions otherwise using malloc(), the size of
  288.     the strings maintained may also be set to a constant via str_init(). The
  289.     str_free() function frees the entire string pool.
  290.     
  291.     In addition to left(), right() and mid() corresponding to BASIC's LEFT$,
  292.     RIGHT$, and MID$ functions, The MicroFirm Function Library adds the
  293.     string_add() string concatenation function as an analogue of BASIC's
  294.     "A$=A$+B$+C$" syntax.
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331. JULFUNCS.TXT - Thu 23 Nov 89 00:20 - Page 6:  
  332.  
  333.     The Julian date conversion routines convert dates in standard year,
  334.     month, and date formats to and from Julian dates. Note that these are
  335.     not true Julian dates based on the Julian calendar, but are scalar
  336.     numbers representing the number of days since Jan 1, 0001. As such they
  337.     may be used for calculating the number of days between two dates, etc.
  338.     Two additional functions are supplied for converting Julian date to day
  339.     of the week and day of the year value. The first day of the week
  340.     conversion function, julian_to_wkday(), returns the numerical day of the
  341.     week, starting with Sunday equal to zero. The second day of the week
  342.     conversion routine, julian_to_dayname() returns the name of the day as
  343.     specified for the current locale - see setlocale() for more details. In
  344.     addition to the basic Julian date routines, four symmetrical functions
  345.     are provided to convert Julian dates from and to both time_t values
  346.     and/or tm structures.
  347.     
  348.     
  349.     EXAMPLE
  350.     
  351.             unsigned mo,day,yr;
  352.             long jday1,jday2;
  353.             jday1=ymd_to_julian(1903,1,3);
  354.             jday2=ymd_to_julian(1974,6,9);
  355.             printf("There were %ld days between 1/3/1903 and 6/9/1974\n",
  356.                jday2-jday1);
  357.             printf("6/9/74 (day # %d) was a %s\n",
  358.                julian_to_yrday(jday2), julian_to_wkday(jday2));
  359.             printf("That is %f years\n", (double)(jday2-jday1)/365.2425);
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.